package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDTO;
import com.zzyl.entity.NursingLevel;
import com.zzyl.entity.NursingPlan;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/nursing/plan")
public class NursingPlanController extends BaseController{

    @Resource
    NursingPlanService nursingPlanService;

    @GetMapping("/search")
    public ResponseResult searchByPage(@RequestParam(required = false) String name,
                                       @RequestParam(required = false) Integer status,
                                       @RequestParam(required = false) Integer pageNum,
                                       @RequestParam(required = false) Integer pageSize){
        PageResponse<NursingPlanVO> query = nursingPlanService.searchByPage(name, status, pageNum, pageSize);
        return success(query);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody NursingPlanDTO dto){
        Long userIdByName = getUserIdByName();
        return success(nursingPlanService.insert(dto,userIdByName));
    }

}
